import axios from 'axios'

export function request(config) {
  //创建实例
  const instance1 = axios.create({
    baseURL:'http://127.0.0.1:8888/api/private/v1/',
    timeout: 5000,
    // withCredentials: true
  })
  //请求拦截,带上token 
  instance1.interceptors.request.use(config => {
    let token = window.sessionStorage.getItem('token')
    token && (config.headers.Authorization = token)
    return config;
  },err => {
    return Promise.reject(err)
  })
  //响应后发送数据前拦截
  // instance1.interceptors.response.use(res => {
  //   return res.data
  // }, err => {
  //   console.log(err);
  // })
  //发送真正的网络请求
  return instance1(config)
}

